*Test for differences in predictive accuracy - monthly
clear


*Load Macro data
import excel using macrodata.xlsx, firstrow clear sheet("Macrodata12")
sort yy
save temp, replace


import excel using Results.xlsx, sheet("Predictions12") first clear
merge m:m yy using temp
drop _merge
sort yy

save temp, replace


*Dummy for start of second half of sample period (yyyymm)
local secondhalf=199401
gen dummy2=yyyymm>=`secondhalf'


*Clark-West mean-adjusted errors
foreach var of varlist mean-dmspe1{
	gen f`var'=(lnexret-modelmean)^2-((lnexret-`var')^2-(modelmean-`var')^2)
}	


*Tercile dummies for macro variables
foreach var of varlist rgdp-rcf{
	capture drop xt*
	egen xt1=pctile(`var'), p(33.3)
	egen xt2=pctile(`var'), p(66.6)
	gen d`var'=0
	replace d`var'=-1 if `var'<=xt1
	replace d`var'=1 if `var'>xt2
	gen b`var'=`var'<=xt1
	gen g`var'=`var'>xt2

	
}


*Run one regression to be able to append all others
reg fmean dummy2
outreg2 using "differencereg12.xls", replace dec(4) stats(coef tstat) adjr2

*Regressions for Panel A
foreach var of varlist fmean-fdmspe1{
	reg `var' dummy2
	outreg2 using "differencereg12.xls", append dec(4) stats(coef tstat) adjr2	
}

*Regressions for Panel B
foreach var of varlist fmean-fdmspe1{
	reg `var' dummy2 NBER
	outreg2 using "differencereg12.xls", append dec(4) stats(coef tstat) adjr2	
}

*Regressions for Panel C
foreach var of varlist fmean-fdmspe1{
	reg `var' dummy2 NBER brgdp grgdp brp grp brcf grcf
	outreg2 using "differencereg12.xls", append dec(4) stats(coef tstat) adjr2
}




